package com.kpmg.datalake.accountcheck.model;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.math.BigDecimal;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author Echo
 * @create 2018-06-29
 * @desc
 */
public class AccountOrigin extends BaseAccountCheck {
	
	private static final Logger logger = LoggerFactory.getLogger(AccountOrigin.class);

    /**
	 * 
	 */
	private static final long serialVersionUID = -1474073939682603831L;

	/**
     * 主键
     */
    private String dtlId;

    /**
     * 是否匹配过， 1:匹配, 0:未匹配
     */
    private Integer mtchInd;

    /**
     * 抵消金额, AMT_OFST
     */
    private BigDecimal amtOfst;
    
    /**
     * 差异金额
     */
    private BigDecimal diffEop;
    
    /**
     * 交易对手标准名称
     */
    private String cstStdNm;
    
    /**
     * 自定义属性, 用来判断该数据是否被科目配置过
     */
    private Boolean definedBySubject = Boolean.FALSE;

  /**
   * 匹配规则id
   */
  private String mappingId;

    /**
     * 差异金额
     * @return
     */
    public String getDtlId() {
        return dtlId;
    }

    public void setDtlId(String dtlId) {
        this.dtlId = dtlId;
    }

    public Integer getMtchInd() {
        return mtchInd;
    }

    public void setMtchInd(Integer mtchInd) {
        this.mtchInd = mtchInd;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        AccountOrigin that = (AccountOrigin) o;

        return dtlId != null ? dtlId.equals(that.dtlId) : that.dtlId == null;

    }

    @Override
    public int hashCode() {
        return dtlId != null ? dtlId.hashCode() : 0;
    }

    public BigDecimal getDiffEop() {
        return diffEop;
    }

    public void setDiffEop(BigDecimal diffEop) {
        this.diffEop = diffEop;
    }
	
	public String getCstStdNm() {
		return cstStdNm;
	}

	public void setCstStdNm(String cstStdNm) {
		this.cstStdNm = cstStdNm;
	}

	public Boolean getDefinedBySubject() {
		return definedBySubject;
	}

	public void setDefinedBySubject(Boolean definedBySubject) {
		this.definedBySubject = definedBySubject;
	}

	public BigDecimal getAmtOfst() {
		return amtOfst;
	}

	public void setAmtOfst(BigDecimal amtOfst) {
		this.amtOfst = amtOfst;
	}
	
	public AccountOrigin deepClone() {
		AccountOrigin cloneObj = null;
        try {
            //写入字节流
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            ObjectOutputStream obs = new ObjectOutputStream(out);
            obs.writeObject(this);
            obs.close();
            
            //分配内存，写入原始对象，生成新对象
            ByteArrayInputStream ios = new ByteArrayInputStream(out.toByteArray());
            ObjectInputStream ois = new ObjectInputStream(ios);
            //返回生成的新对象
            cloneObj = (AccountOrigin) ois.readObject();
            ois.close();
        } catch (Exception e) {
            logger.error("clone AccountOrigin Exception: " + e.getMessage(), e);
        }
        return cloneObj;
    }

  public String getMappingId() {
    return mappingId;
  }

  public void setMappingId(String mappingId) {
    this.mappingId = mappingId;
  }
}
